package com.teach;

import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import com.teach.model.Student1;
import com.teach.model.Student2;

public class HashSetTest {

	public static void main(String[] args) {
		Set<Long> set1 = new HashSet<Long>();
		System.out.println("set1.add(1L):"+set1.add(1L));
		System.out.println("set1.add(3L):"+set1.add(3L));
		System.out.println("set1.add(2L):"+set1.add(2L));
		System.out.println("set1.add(3L):"+set1.add(3L));
		System.out.println("set1="+set1);
		
		List<Long> list = Arrays.asList(1L,3L,2L,3L);
		System.out.println("list:"+list);
		Set<Long> set2 = new HashSet<Long>(list);
		System.out.println("set2="+set2);
		
		Set<Student1> set3 = new HashSet<Student1>();
		set3.add(new Student1(1L, "aaa"));
		set3.add(new Student1(3L, "bbb"));
		set3.add(new Student1(2L, "ccc"));
		set3.add(new Student1(3L, "bbb"));
		System.out.println("set3="+set3);
		
		Set<Student2> set4 = new HashSet<Student2>();
		set4.add(new Student2(1L, "aaa"));
		set4.add(new Student2(3L, "bbb"));
		set4.add(new Student2(2L, "ccc"));
		set4.add(new Student2(3L, "bbb"));
		System.out.println("set4="+set4);
		Student2 s1 = new Student2(4L, "ddd");
		set4.add(s1);
		System.out.println("set4="+set4);
		s1.setId(1L);
		s1.setName("aaa");
		System.out.println("set4="+set4);
		set4 = new HashSet<Student2>(set4);
		System.out.println("set4="+set4);
		set4.add(null);
		set4.add(null);
		set4.add(null);
		set4.add(null);
		set4.add(null);
		System.out.println("set4="+set4);
		
	}
}
